﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using MQC.board;

namespace MQC
{
    public partial class WebForm1 : System.Web.UI.Page
    {
        public static int index;
        protected void Page_Load(object sender, EventArgs e)
        {
            if(!IsPostBack)
            {
                index = 0;
            }
            else
            {
                index = index + 1;
            }
            Bind();
        }
        public void Bind()
        {
            double count;
            using (DbAppDataContext db = new DbAppDataContext())
            {
                var data = from m in db.Record
                           select new DataType { Batch = m.Batch, Maktx = m.Maktx, Mold = m.Mold };
                var list = data.ToList();
                GridView1.DataSource = list;
                count = list.Count / 10;
                if(index-1>=count)
                {
                    index = 0;
                }
                GridView1.PageIndex = index;
                GridView1.DataBind();
            }
        }

        protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e)
        {
            GridView1.PageIndex = e.NewPageIndex;
            Bind();
        }
    }
}